package edu.gym4all.view;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

import com.example.gym4all.R;

import edu.gym4all.service.domain.Training;

public class TrainingTypeActivity extends Activity {

	@Override
	public void onCreate(Bundle bundle) {
		super.onCreate(bundle);
		this.setContentView(R.layout.training_type_page);

		Button hyperButton = (Button) this.findViewById(R.id.hipertrophyButton);
		Button cardioButton = (Button) this.findViewById(R.id.cardioButton);

		hyperButton
				.setOnClickListener(new OnClickHyperButton(this.getIntent()));

		cardioButton.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				Intent intent = new Intent(TrainingTypeActivity.this,
						CardioExercisesActivity.class);
				TrainingTypeActivity.this.startActivity(intent);
			}
		});
	}

	private class OnClickHyperButton implements OnClickListener {

		Intent intentMainActivity;

		public OnClickHyperButton(Intent intent) {
			this.intentMainActivity = intent;
		}

		@Override
		public void onClick(View v) {
			Intent intent = new Intent(TrainingTypeActivity.this,
					MuscleTypeActivity.class);
			Training training = (Training) this.intentMainActivity
					.getParcelableExtra("training");
			intent.putExtra("training", training);
			TrainingTypeActivity.this.startActivity(intent);
		}
	}
}
